﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Tong;

public partial class aspnet_admin_bock_Gbook_CX_GBook_Add : System.Web.UI.Page
{    /// <summary>
    /// 数据操作通用类 实例 TextData
    /// </summary> 
    public Tong.TongUse TextData = new Tong.TongUse();

    /// <summary>
    /// 系统安装绝对路径
    /// </summary>
    public string Abs_Path = TongUse.SysPath;
    /// <summary>
    /// 用户存放数据的临时表
    /// </summary>
    DataTable MyDt = new DataTable();


    /// <summary>
    /// 站点通用方法类
    /// </summary>
    public Tong.ThisSiteUse.SiteTong TextThisSite = new Tong.ThisSiteUse.SiteTong();
    
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            DataSavave();
        }
        else
        {
            CX_Gbook_Doctor.DataSource = TextData.SqlataSet("select CX_News_Name from  [CX_Doctor] ");
            CX_Gbook_Doctor.DataTextField = "CX_Doctor_Name";
            CX_Gbook_Doctor.DataValueField = "CX_Doctor_Name";
            CX_Gbook_Doctor.DataBind();
           
        }
    }

    /// <summary>
    /// 添加保存留言
    /// </summary>
    public void DataSavave()
    {
        string CX_Gbook_Sex = "";
        string CX_Gbook_From = "";
        string xx = CX_Gbook_lx.Value;
        try
        {
            CX_Gbook_Sex = Request.Form["CX_Gbook_Sex"].Trim();
            CX_Gbook_From = Request.Form["CX_Gbook_From"].Trim();
            if (xx == "")
            { 
                xx = "0"; 
            }

            
        }
        catch
        { 
        
        }



        string sql = "";
        sql = "INSERT INTO [CX_Gbook] ([CX_Gbook_Name]" +
          " ,[CX_Gbook_Creater]" +
          " ,[CX_Gbook_Doctor]" +
          " ,[CX_Gbook_From]" +
          " ,[CX_Gbook_Address]" +
          " ,[CX_Gbook_Pic_Url]" +
          " ,[CX_Gbook_Tel]" +
          " ,[CX_Gbook_QQ]" +
          " ,[CX_Gbook_Email]" +
          " ,[CX_Gbook_Sex]" +
          " ,[CX_Gbook_lx]" +
          " ,[CX_Gbook_IP]" +
          " ,[CX_Gbook_PublicTime]" +
          " ,[CX_Gbook_Cont])\r\n" +
     " VALUES" +
          "('" + CX_Gbook_Name.Text.Trim().Replace("'", "").Replace("<", "&lt;").Replace(">", "&gt;") + "'" +
          " ,'" + CX_Gbook_Creater.Text.Trim().Replace("'", "").Replace("<", "&lt;").Replace(">", "&gt;") + "'" +
          " ,'" + CX_Gbook_Doctor.Text.Trim().Replace("'", "").Replace("<", "&lt;").Replace(">", "&gt;") + "'" +
          " ,'" + CX_Gbook_From.Trim().Replace("'", "").Replace("<", "&lt;").Replace(">", "&gt;") + "'" +
          " ,'" + CX_Gbook_Address.Text.Trim().Replace("'", "").Replace("<", "&lt;").Replace(">", "&gt;") + "'" +
          " ,''" +//CX_Gbook_Pic_Url
          " ,'" + CX_Gbook_Tel.Text.Trim().Replace("'", "").Replace("<", "&lt;").Replace(">", "&gt;") + "'" +
          " ," + CX_Gbook_QQ.Text.Trim().Replace("'", "").Replace("<", "&lt;").Replace(">", "&gt;") + "" +
          " ,'" + CX_Gbook_Email.Text.Trim().Replace("'", "").Replace("<", "&lt;").Replace(">", "&gt;") + "'" +
          " ,'" + CX_Gbook_Sex.Trim().Replace("'", "").Replace("<", "&lt;").Replace(">", "&gt;") + "'" +
          " ," + xx + "" +
          " ,'" + Request.UserHostAddress.Trim().Replace("'", "").Replace("<", "&lt;").Replace(">", "&gt;") + "'" +
          " ,'" + DateTime.Now.ToString() + "'" +//CX_Gbook_PublicTime
          " ,'" + CX_Gbook_Cont.Text.Trim().Replace("'", "").Replace("<", "&lt;").Replace(">", "&gt;") + "')";


        TextData.SqlDataSave(sql);
        TextData.ResonseAlert("添加留言成功");          
            
    }
}
